import axios from 'axios';
import {
  SignInCmd,
  SignInView,
  SignUpCmd,
  SignUpView,
  User,
  UserPermissionView,
} from '@/types/idm/user';

export function doUserSignUp(data: SignUpCmd) {
  return axios.post<SignUpView>('/open/idm/user/sign-up', data);
}

export function doUserSignIn(data: SignInCmd) {
  return axios.post<SignInView>('/open/idm/user/sign-in', data);
}

export function doUserSignOut() {
  return axios.post('/open/idm/user/sign-out');
}

export function fetchUserCurrent() {
  return axios.get<User>('/idm/user/current');
}

export function fetchUserCurrentPermission() {
  return axios.get<UserPermissionView>('/idm/user/current-user-role');
}
